package sugarbind_input
import org.apache.tomcat.jni.Error;

import javassist.bytecode.stackmap.BasicBlock.Catch;
import grails.converters.*
import groovyx.gpars.extra166y.CommonOps.LongAdder;

class Article_TypeController {

    def scaffold = Article_Type
	
	//def ddlarticles = {}
	
	def findArticles = {
		println("findArticles params : " +params)		
			
		def article_Type 
		def articles
		
		try
		{
			article_Type = Article_Type.get(params.article_Type.id)
			println("article_Type : "+article_Type)
		}
		catch(Exception ex)
		{	
			println(ex.getMessage())
		}

		if(article_Type != null)
		{				
			articles = article_Type.articles
//			render(template: 'ddlArticles', model:  [articles : article_Type.articles])
		}
		else
		{
			articles = Article.listArticles()				
		}
		render(template: 'ddlArticles', model:  [articles : articles])
	  }
	
	def findArticle_Types = {
		println("findArticle_Types params : " +params)
			
		def article_Types = Article_Type.listArticle_Types()
		def selected


		try
		{
			selected = Article_Type.get(params.article_Type.id)
		}
		catch(Exception ex)
		{	
			println(ex.getMessage())
		}
		println(article_Types)
		println(selected) 
		
		render(template: 'ddlArticle_Types', model:  [article_Types : article_Types, selected:selected])
	  }
}
